package com.zhuhjay.common.core.security.custom;

import com.zhuhjay.common.core.security.filter.BasicTokenVerifyFilter;
import com.zhuhjay.common.core.security.handler.AuthenticationEntryPointImpl;
import com.zhuhjay.common.core.security.handler.CustomerLogoutHandler;
import com.zhuhjay.common.core.security.handler.CustomerLogoutSuccessHandler;
import com.zhuhjay.common.security.custom.SecurityFilterHolder;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.security.web.authentication.logout.LogoutHandler;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author ZhuHJay
 * @date 2023/8/4 10:53
 */
@Component
class SecurityFilterHolderImpl implements SecurityFilterHolder {

    @Resource
    private AuthenticationManager authenticationManager;

    @Override
    public BasicAuthenticationFilter authenticationFilter() {
        return new BasicTokenVerifyFilter(authenticationManager);
    }

    @Override
    public AuthenticationEntryPoint authenticationEntryPoint() {
        return new AuthenticationEntryPointImpl();
    }

    @Override
    public LogoutHandler logoutHandler() {
        return new CustomerLogoutHandler();
    }

    @Override
    public LogoutSuccessHandler logoutSuccessHandler() {
        return new CustomerLogoutSuccessHandler();
    }
}
